﻿window.App = new Vue({
    el: "#app",
    data: {
        IfCheck: false,
        UserName: "",
        PassWord: "",
        BinGp: false,
        BinMsg: ""
    },
    methods: {
        INIT: function () {
            var that = this;
            $.ajax({
                url: "/Login.aspx?parms=GetCheckLoginInfo",
                async: true,
                type: "POST",

                success: function (result) {
                    if (result.Type == 1) {
                        that.UserName = result.Data.UserName;
                        that.PassWord = result.Data.PassWord;
                        that.IfCheck = true;
                        return;
                    }
                },
                error: function (result) {
                }
            });
        },
        LOGIN_CLICK: function () {
            var that = this;
            if (this.UserName.trim() == "") {
                alert("用户名不能为空");
                return;
            }
            if (this.PassWord.trim() == "") {
                alert("密码不能为空");
                return;
            }
            var OpearInfo = function () {
                this.ToKenKey = "";
                this.OpearUserKey = "";
                this.OpearUserName = "";
                this.OpearDate = new Date();
                this.OpearProxyIp = "";
                this.Data = null;
                this.Reload = function (data) {
                    this.Date = new Date();
                    if (data == undefined) {
                        this.Data = null;
                    }
                    else {
                        this.Data = data;
                    }
                    return this;
                };
            };

            that.BinGp = 1;

            $.ajax({
                url: "/Login.aspx?parms=CheckLogin",
                async: true,
                type: "POST",
                data: JSON.stringify({ UserName: this.UserName, PassWord: this.PassWord, IfCheck: this.IfCheck }),
                success: function (result) {
                    that.BinGp = 2;
                    that.BinMsg = result.Msg;
                    setTimeout(function () {
                        if (result.Type == 1) {
                            window.location.href = "/Index.html";
                            return;
                        }
                        else {
                            that.BinGp = 0;
                        }
                    }, 2000);
                },
                error: function (result) {
                    that.BinGp = 2;
                    console.log(result);
                    that.BinMsg = "网络或者服务接口异常";
                    setTimeout(function () {
                        that.BinGp = 0;
                    }, 2000);
                }
            });
        }
    },
    mounted: function () {
        this.INIT();
    }
});